package com.situ.day1;

import org.junit.Test;

import java.util.Scanner;

public class Hello {

    //main
    public static void main(String[] args) {
        //sout
        System.out.println("HelloWorld");
        //Console
        //张三的年龄是23
        //变量
        int age = 23;
        age = 24;
        final int age1 = 24;
        //Cannot assign a value to final variable 'age1'
        //age1 = 25;
        //int public = 45;
    }

    //Alt+Enter 快速修复一次错误
    @Test
    public void test1() {
        //soutm
        System.out.println("Hello.test1");
    }

    @Test
    public void test2() {
        //soutm
        System.out.println("Hello.test2");
        char ch1 = 'a';
        char ch2 = '中';
        System.out.println(ch2);

        double d = 3.14;
        int i = (int)d;
        System.out.println(i);

    }

    @Test
    public void test65() {
        int num1 = 3;
        int num2 = 5;
        int reulst =  num1 + num2;
        System.out.println(reulst);

        int i = 1;
        i = i + 1;
        System.out.println(i);//2
        i++;//i = i + 1;
        System.out.println(i);//3
        System.out.println(i++);//3
        System.out.println(i);//4
        System.out.println(++i);//5
        System.out.println(i);//5

    }

    @Test
    public void test156() {
        System.out.println(3 > 5);
        int num1 = 3;
        int num2 = 5;
        System.out.println(num1 > num2);
        boolean bool = num1 > num2;
        System.out.println(bool);
    }

    @Test
    public void test145() {
        int score1 = 78;
        int score2 = 390;
        boolean bool1 = score1 >= 60 && score2 >= 400;
        System.out.println(bool1);
        boolean bool2 = score1 >= 60 || score2 >= 400;
        System.out.println(bool2);

    }

    @Test
    public void test1199() {
        //int score = 65;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩:");
        int score = scanner.nextInt();
        if (score >= 90 && score <= 100) {
            System.out.println("优秀");
        } else if (score >= 80 && score < 90) {
            System.out.println("良好");
        }
    }

    @Test
    public void test566() {
        //while   for
        //每打印一次count+1   count <= 5
        int count = 1;
        while (count <= 5) {
            System.out.println("HelloWorld");
            count++;//count = count + 1
        }
    }

    @Test
    public void test56() {
        //i,j,k
        for (int i = 1; i <= 5; i++) {
            System.out.println("i: " + i);
            System.out.println("HelloWorld");
        }
    }

    @Test
    public void test562() {
        // sum = 1+2+3+4+5+6+...+99+100
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            System.out.println(i);
            sum = sum + i;
        }
        System.out.println("sum: " + sum);
    }

    //统计思想，数一下符合条件的有多少个（计算1-100以内7的倍数的个数）
    @Test
    public void test900 () {
        //7,14,21,28....
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 7 == 0) {
                System.out.println(i);
                count++;
            }
        }
        System.out.println("count: " + count);
    }

    @Test
    public void test44() {
        for (int i = 1; i <= 5; i++) {
            if (i == 3) {
                continue;
            }
            System.out.println(i);
        }
    }

    @Test
    public void test46() {
        for (int i = 1; i <= 5; i++) {
            if (i == 3) {
                break;
            }
            System.out.println(i);
        }
    }

    //    ****
//    ****
//    ****
    @Test
    public void test90 () {
        for (int i = 1; i <= 3; i++) {
            //i=1 代表打印第一行
            for (int j = 1; j <= 4; j++) {
                System.out.print("*");
            }
            //打印完一行之后换行，接下来i++，打印下一行
            System.out.println();
        }
    }

    @Test
    public void test99() {
        //****
        for (int i = 1; i <= 4; i++) {
            System.out.print("*");
        }
        //换行
        System.out.println();
        //*
        //*
        //*
        for (int i = 1; i <= 3; i++) {
            System.out.println("*");
        }
    }

    //    *
//    **
//    ***
//    ****
//    *****
    @Test
    public void test88() {
        for (int i = 1; i <= 5; i++) {
            //i=1 j=1   代表打印第一行
            //i=2 j=2
            //i=3 j=3
            for (int j= 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    @Test
    public void test999() {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                //System.out.print("2*7=14\t");
                System.out.print(j+"*"+i+"="+(i*j)+"\t");
            }
            System.out.println();
        }
    }

    @Test
    public void test45 () {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
                System.out.println("31天");
                break;
            case 2:
                System.out.println("28/29天");
                break;
            case 3:
                //Duplicate branch in 'switch'
                System.out.println("31天");
                break;
            case 4:
                System.out.println("30天");
                break;
            case 5:
                System.out.println("31天");
                break;
        }
    }

    @Test
    public void test467 () {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
                System.out.println("31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("30天");
                break;
            case 2:
                System.out.println("28/29天");
                break;

        }
    }


    //    之前用if-else做的程序，使用switch完成：
//    >=90    <=100      优秀
//    >=80    <90        良好
//    >=70    <80        一般
//    >=60    <70        及格
//    <60                不及格
    @Test
    public void test199() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩：");
        int score = scanner.nextInt();
        switch (score / 10) {
            case 9:
            case 10:
                System.out.println("优秀");
                break;
            case 8:
                System.out.println("良好");
                break;
            case 7:
                System.out.println("一般");
                break;
            case 6:
                System.out.println("及格");
                break;
            default:
                System.out.println("不及格");
                break;
        }
    }

    @Test
    public void test89() {
        int[] array = new int[4];
        System.out.println("length: " + array.length);//4
        array[0] = 33;
        array[1] = 2;
        array[2] = 45;
        array[3] = 19;
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
        System.out.println("----------");
        for (int i = array.length - 1; i >= 0; i--) {
            System.out.println(array[i]);
        }
    }

    @Test
    public void test189() {
//        int[] array = new int[4];
//        array[0] = 33;
//        array[1] = 2;
//        array[2] = 45;
//        array[3] = 19;
        int[] array = {33, 2, 45, 19};
        //array.fori
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum = sum + array[i];
        }
        System.out.println("sum: " + sum);
    }

    @Test
    public void test187() {
        int[] array = {33, 2, 45, 19, 56};
        int max = array[0];
        for (int i = 0; i < array.length; i++) {
            if (array[i] > max) {
                max = array[i];
            }
        }
        System.out.println("max: " + max);
    }

    @Test
    public void test587() {
        int[] array = {45, 67, 3, 98, 5};
        int max = getMax(array);
        System.out.println("max: " + max);
    }

    public int getMax(int[] array) {
        int max = array[0];
        for (int i = 0; i < array.length; i++) {
            if (array[i] > max) {
                max = array[i];
            }
        }
        return max;
    }

    @Test
    public void test1999() {
        //i=1   j=3
        //i=2   j=2
        //i=3   j=1
        //i+j=array.length
        //j=array.length-i
        int[] array = {40, 17, 21, 1};
        for (int i = 1; i <= array.length - 1; i++) {
            for (int j = 0; j < array.length - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }

        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }


}
